package com.github.prontera.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.github.prontera.ApiVersion;
import com.github.prontera.RequestLogging;
import com.github.prontera.common.filter.CurrentUserId;
import com.github.prontera.domain.Consume;
import com.github.prontera.domain.enums.ConsumeSmallTypeEnum;
import com.github.prontera.domain.enums.ConsumeLevelTypeEnum;
import com.github.prontera.model.response.ObjectDataResponse;
import com.github.prontera.service.ConsumeService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;


/**
 * 消费记录
 */
@RestController
@Api(value = "消费记录")
@RequestMapping(value = ApiVersion.API_V1_PREFIX+"/consume")
public class ConsumeController{

	@Autowired
	private ConsumeService consumeService;
	
	
	@RequestMapping(value = "balance", method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation(value = "余额列表" , notes = "余额列表")
	public ObjectDataResponse<List<Consume>> balance(@ApiParam(hidden=true,name="登录用户ID")@CurrentUserId Long clientId,@RequestBody Consume consume){
		consume.setClientId(clientId);
		consume.setLevelType(ConsumeLevelTypeEnum.BALANCE);
		consume.setOrderBy("U_CONSUME.create_time desc");
		List<Consume> datas=consumeService.find(consume);
		return new ObjectDataResponse<List<Consume>>(datas);
	}
	
	
	@RequestMapping(value = "mybean", method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation(value = "唐豆豆列表" , notes = "唐豆豆列表")
	public ObjectDataResponse<List<Consume>> mybean(@ApiParam(hidden=true,name="登录用户ID")@CurrentUserId Long clientId,@RequestBody Consume consume){
		consume.setClientId(clientId);
		consume.setLevelType(ConsumeLevelTypeEnum.BEAN);
		consume.setOrderBy("U_CONSUME.create_time desc");
		List<Consume> datas=consumeService.find(consume);
		return new ObjectDataResponse<List<Consume>>(datas);
	}
	
	
	@RequestMapping(value = "consume", method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation(value = "消费记录列表" , notes = "消费记录列表")
	public ObjectDataResponse<List<Consume>> consume(@ApiParam(hidden=true,name="登录用户ID")@CurrentUserId Long clientId,@RequestBody Consume consume){
		consume.setClientId(clientId);
		consume.setOrderBy("U_CONSUME.create_time desc");
		List<Consume> datas=consumeService.find(consume);
		return new ObjectDataResponse<List<Consume>>(datas);
	}
	
	
	@RequestMapping(value = "deposit", method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation(value = "提现记录列表" , notes = "提现记录列表")
	public ObjectDataResponse<List<Consume>> deposit(@ApiParam(hidden=true,name="登录用户ID")@CurrentUserId Long clientId,@RequestBody Consume consume){
		consume.setClientId(clientId);
		consume.setLevelType(ConsumeLevelTypeEnum.DEPOSIT);
		consume.setConsumeType(ConsumeSmallTypeEnum.DEPOSIT);
		consume.setOrderBy("U_CONSUME.create_time desc");
		List<Consume> datas=consumeService.find(consume);
		return new ObjectDataResponse<List<Consume>>(datas);
	}
	 
}
